<%@ page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<c:if test="${ paginator.items > 0 }">
	<div class="tb-page fn-clear">
		<c:choose>
			<c:when test="${paginator.items<paginator.itemsPerPage}">
				<div class="fn-left">显示第 1 - ${paginator.endIndex} 条记录，共${paginator.items}条记录</div>
			</c:when>
			<c:otherwise>
				<div class="fn-left">显示第 ${paginator.beginIndex} - ${paginator.endIndex} 条记录，共${paginator.items}条记录</div>
			</c:otherwise>
		</c:choose>
		<div class="fn-right fn-clear">
			<span class="fn-left">当前页${paginator.page}/${paginator.pages}</span> <span><a onclick="document.getElementById('${param.currentPage}').value=1;document.getElementById('${param.formName}').submit()">首页</a></span>
			<c:choose>
				<c:when test="${paginator.page<=1}">
					<span class="nolink">上一页</span>
				</c:when>
				<c:otherwise>
					<span><a onclick="document.getElementById('${param.currentPage}').value=${paginator.page-1};document.getElementById('${param.formName}').submit()">上一页</a></span>
				</c:otherwise>
			</c:choose>
			<c:set var="listbegin" value="1"/>
			<c:set var="liststep" value="5"/>
			<c:set var="pageCount" value="0"/>
			<c:set var="page2" value="1"/>
			<c:set var="listend" value="1"/>
			<c:if test="${paginator.pages != null}">
				<c:set var="pageCount" value="${paginator.pages}"/>
			</c:if>
			<c:if test="${paginator.page != null}">
				<c:set var="page2" value="${paginator.page}"/>
			</c:if>
			<c:set var="listend" value="${paginator.pages}"/>
			<c:if test="${paginator.pages > 5}">
				<c:if test="${page2 <=5 }">
					<c:set var="listbegin" value="1"/>
					<c:set var="listend" value="5"/>
				</c:if>
				<c:if test="${page2 >5 }">
					<fmt:formatNumber var="num" type="number" value="${(page2-page2%liststep)/liststep}" maxFractionDigits="0"/>
					<c:set var="listbegin" value="${1+5*num}"/>
					<c:if test="${page2%liststep ==0}">
							<c:set var="listbegin" value="${1+5*(num-1)}"/>
					</c:if>
					<c:if test="${(pageCount - listbegin) <= 4} ">
						<c:set var="listend" value="${pageCount}"/>
					</c:if>
					<c:if test="${(pageCount - listbegin) > 4}">
						<c:set var="listend" value="${listbegin + (liststep-1)}"/>
					</c:if>
				</c:if>
			</c:if>
			<c:if test="${pageCount >=1 }">
				<c:forEach var="pagenum" begin="${listbegin }" end="${listend }" step="1">
					<c:choose>
						<c:when test="${paginator.page == pagenum}">
							<span><a class="act" onclick="document.getElementById('${param.currentPage}').value=${pagenum};document.getElementById('${param.formName}').submit()">${pagenum}</a></span>
						</c:when>
						<c:otherwise>
							<span><a onclick="document.getElementById('${param.currentPage}').value=${pagenum};document.getElementById('${param.formName}').submit()">${pagenum}</a></span>
						</c:otherwise>
					</c:choose>
				</c:forEach>
			</c:if>
			<c:choose>
				<c:when test="${paginator.page>=paginator.pages}">
					<span class="nolink">下一页</span>
				</c:when>
				<c:otherwise>
					<span><a onclick="document.getElementById('${param.currentPage}').value=${paginator.page+1};document.getElementById('${param.formName}').submit()">下一页</a></span>
				</c:otherwise>
			</c:choose>
			<span>
				<a onclick="document.getElementById('${param.currentPage}').value=${paginator.pages};document.getElementById('${param.formName}').submit()">末页</a>
			</span>
			<span><input type="text" class="i-text" value="" name="pageNum" id="pageID"></span>
			<script type="text/javascript">
				function Breturn(){
					if(document.getElementById('pageID').value !="" && document.getElementById('pageID').value <= ${paginator.pages}){
						document.getElementById('${param.currentPage}').value=document.getElementById('pageID').value;
					}else if(document.getElementById('pageID').value !="" && document.getElementById('pageID').value > ${paginator.pages}){
						document.getElementById('${param.currentPage}').value = ${paginator.pages};
					}else{
						document.getElementById('${param.currentPage}').value = 1;
					}
					document.getElementById('${param.formName}').submit();
				}
			</script>
			<span><input type="button" value="跳转" class="i-button" onclick="Breturn();"></span>
		</div>
	</div>
</c:if>